package com.mb;

import java.io.Serializable;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

import com.facade.CountryFacade;
import com.model.Country;

@ViewScoped
@ManagedBean
public class CountryMB extends AbstractMB implements Serializable {
	private static final long serialVersionUID = 1L;
	
	private Country country;
	private List<Country> countries; 
	private CountryFacade countryFacade; 
	
	public List<Country> getAllCountries() {
		if (countries == null) {
			loadCountries();
		}

		return countries;
	}

	private void loadCountries() {
		countries = getCountryFacade().listAll();
	}

	public Country getCountry() {
		if(country == null){
			country = new Country();
		}
		return country;
	}

	public void setCountry(Country country) {
		this.country = country;
	}

	public List<Country> getCountries() {
		if(countries == null){
			countries = getAllCountries();
		}
		return countries;
	}

	public void setCountries(List<Country> countries) {
		this.countries = countries;
	}

	public CountryFacade getCountryFacade() {
		if(countryFacade == null){
			countryFacade = new CountryFacade();
		}
		return countryFacade;
	}

	public void setCountryFacade(CountryFacade countryFacade) {
		this.countryFacade = countryFacade;
	}
	

}
